<?php

namespace common\models\app;

use Yii;

/**
 * This is the model class for table "{{%app_discover}}".
 *
 * @property int $id
 * @property string $path
 * @property int $status 状态
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 * @property int $deleted_at
 */
class AppDiscover extends \common\db\ActiveRecord {

    use \common\traits\Constants;

    const STATUS_DEFAULT = 0;
    const STATUS_ACTIVE = 10;

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%app_discover}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['status', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
            [['path'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'path' => 'Path',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
            'deleted_at' => 'Deleted At',
        ];
    }

    public static function findCurrent() {
        return static::find()->active(static::STATUS_ACTIVE)->orderBy([
            'updated_at' => SORT_DESC,
        ])->one();
    }

    /**
     * {@inheritdoc}
     */
    public function fields() {
        return [
            'id' => 'ID',
            'path' => 'Path',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
            'deleted_at' => 'Deleted At',
        ];
    }

}
